//
//  houseInfoTableViewCell.m
//  sellHouse
//
//  Created by 李 佳伟 on 2018/11/22.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "houseInfoTableViewCell.h"
#import "JTCSM.h"
#import "HouserInfoModel.h"

static CGFloat space = 15;
static CGFloat top = 18;
static CGFloat labelheight = 17;
static CGFloat imagesize = 30;

@interface houseInfoTableViewCell ()
{
    UILabel *statuslabel;
}

@property (nonatomic,strong) UILabel *nameLabel;

@property (nonatomic,strong) UIImageView *bottomImageV;

@end

@implementation houseInfoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat labelwidth = 32;
        self.nameLabel = [UILabel initWithFrame:CGRectMake(space, top, KSCREENWidth-space*2-labelwidth-10, labelheight) text:@"海外学子创业园" font:17 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
        [self.contentView addSubview:self.nameLabel];
        statuslabel =[UILabel initWithFrame:CGRectMake(KSCREENWidth-space-labelwidth, top, labelwidth, labelheight) text:@"海外学子创业园" font:10 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(255, 119, 24, 1) backgroundColor:nil];
        [self.contentView addSubview:statuslabel];
        [df layerWithView:statuslabel radius:3 width:1 color:RGBACOLOR(255, 119, 24, 1)];
        
        [df lineViewWithHeightofTop:top*2+labelheight superView:self.contentView lineHeight:1 space:0];
        CGFloat bottomlabelWidth = (KSCREENWidth-2*space)/2;
        for (int i = 0; i<9; i++) {
            NSLog(@"X:%d-----Y:%d",(i%2),(i/2));
            UILabel *label = [UILabel initWithFrame:CGRectMake(space+bottomlabelWidth*(i%2),KVIEW_Y(self.nameLabel)+ top*2+(labelheight+top)*(i/2), bottomlabelWidth, labelheight) text:@"售价:130万" font:15 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(89, 89, 89, 1) backgroundColor:nil];
            label.tag = 1000+i;
            [self.contentView addSubview:label];
            
        }
        
        self.contentView.userInteractionEnabled = YES;
        self.bottomview = [[UIView alloc]initWithFrame:CGRectZero];
        self.bottomview.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.bottomview];
        self.bottomview.userInteractionEnabled = YES;
       
        
        
        _bottomImageV = [[UIImageView alloc]initWithFrame:CGRectMake((KSCREENWidth-imagesize)/2, 10, imagesize, imagesize)];
       
        [self.bottomview addSubview:_bottomImageV];
        self.bottomImageV.userInteractionEnabled = YES;
        
        
    }
    return self;
}

- (void)setValueWithModel:(id)model{
    HouserInfoModel *new_model = model;
    
     statuslabel.text = new_model.saleStatusStr;
    CGRect statusFrame = [df labelHeightWithContent:statuslabel.text width:100 font:10];
    statuslabel.frame = CGRectMake(KSCREENWidth-Kspace-statusFrame.size.width-10, statuslabel.frame.origin.y, statusFrame.size.width+10, labelheight);
    
    CGFloat fontsize = 15;
    self.nameLabel.text = new_model.address ;
    self.nameLabel.frame = CGRectMake(self.nameLabel.frame.origin.x, self.nameLabel.frame.origin.y, KSCREENWidth-3*Kspace-statusFrame.size.width-10, labelheight);
   
    
    UILabel *oneLabel =    [self.contentView viewWithTag:1000];
    oneLabel.hidden = NO;
    oneLabel.text = [new_model.saleStatus integerValue] == 6?@"售价: --":new_model.totalPrice==nil?@"售价: --":[NSString stringWithFormat:@"售价: %@万元",new_model.totalPrice];
    [df fuwenbenLabel:oneLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *twoLabel =    [self.contentView viewWithTag:1001];
    twoLabel.hidden = NO;
    twoLabel.text = [NSString stringWithFormat:@"上线: %@",new_model.statusTime ];
    [df fuwenbenLabel:twoLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *threeLabel =  [self.contentView viewWithTag:1002];
    threeLabel.hidden = NO;
    threeLabel.text = [NSString stringWithFormat:@"装修: %@",new_model.decoradionStr ];
    [df fuwenbenLabel:threeLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *fourLabel =   [self.contentView viewWithTag:1003];
    fourLabel.hidden = NO;
    fourLabel.text = [NSString stringWithFormat:@"面积: %@㎡",new_model.area ];
    [df fuwenbenLabel:fourLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *fiveLabel =   [self.contentView viewWithTag:1004];
    fiveLabel.hidden = NO;
    fiveLabel.text = [NSString stringWithFormat:@"楼层: %@",new_model.floor ];
    [df fuwenbenLabel:fiveLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *sixLabel =    [self.contentView viewWithTag:1005];
    sixLabel.hidden = NO;
    sixLabel.text = [NSString stringWithFormat:@"朝向: %@",new_model.orientationStr ];
    [df fuwenbenLabel:sixLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *senvenLabel = [self.contentView viewWithTag:1006];
    senvenLabel.hidden = NO;
    senvenLabel.text = [NSString stringWithFormat:@"用途: %@",new_model.purposeStr ];
    [df fuwenbenLabel:senvenLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *eightLabel =  [self.contentView viewWithTag:1007];
    eightLabel.hidden = NO;
    eightLabel.text = [NSString stringWithFormat:@"产权: %@",new_model.propertyRightsStr ];
    [df fuwenbenLabel:eightLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    UILabel *nineLabel =   [self.contentView viewWithTag:1008];
    nineLabel.hidden = NO;
    nineLabel.text = [NSString stringWithFormat:@"户型: %@",new_model.houseType ];
    [df fuwenbenLabel:nineLabel FontNumber:[UIFont systemFontOfSize:fontsize] AndRange:NSMakeRange(0, 3) AndColor:RGBACOLOR(133, 133, 133, 1)];
    
    if ([JTCSMSingle shareSingle].houseCellHeight==278) {
        self.bottomview.frame = CGRectMake(0, KVIEW_Y(nineLabel), KSCREENWidth, 50);
         _bottomImageV.image = [UIImage imageNamed:@"xiangshang2.png"];
    }else{
        self.bottomview.frame = CGRectMake(0, KVIEW_Y(twoLabel), KSCREENWidth, 50);
         _bottomImageV.image = [UIImage imageNamed:@"xiangxia2.jpg"];
        threeLabel.hidden = YES;
        fourLabel.hidden = YES;
        fiveLabel.hidden = YES;
        sixLabel.hidden = YES;
        senvenLabel.hidden = YES;
        eightLabel.hidden = YES;
        nineLabel.hidden = YES;
    }
    
}



@end
